package hra;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class player implements IPlayer
{
	List<Integer> vsechnyTahy = new ArrayList<Integer>();
	typ type = null;
	String jmeno;
	Gui gui = new Gui();

	public player(String Jmeno, typ Type)
	{
		jmeno = Jmeno;
		type = Type;
	}

	@Override
	public typ getTyp() // get type
	{
		return type;
	}

	@Override
	public int tah() // turn
	{
		boolean control = true;
		int num = 0;
		while (control)
		{
			try
			{

				Scanner sc = new Scanner(System.in);
				num = sc.nextInt();
				if (num > 9)
				{
					gui.spatnyVstup();
				}
				else
				{
					control = false;
				}
			}
			catch (Exception e)
			{
				gui.spatnyVstup();
			}
		}
		vsechnyTahy.add(num);
		return num;
	}

	@Override
	public int posledniTah() // last turn
	{
		return vsechnyTahy.get(vsechnyTahy.size() - 1);
	}

	@Override
	public int[] vsechnyTahy() // all turns (probably all numbers that was
								// inputed)
	{
		int[] a = new int[vsechnyTahy.size()];
		for (int i = 0; i < vsechnyTahy.size(); i++)
			a[i] = vsechnyTahy.get(i);
		return a;
	}

	@Override
	public String getJmeno() // get name
	{
		return jmeno;
	}
}